<?php $this->_extends('../_layouts/blank_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.js"></script>
<script type="text/javascript">
$(function(){
	$(".start-price").click(function(){
		$(this).parent().parent().find("input[type='checkbox']").attr("checked", true);
	});
	$(".quantity").click(function(){
		$(this).parent().parent().find("input[type='checkbox']").attr("checked", true);
	});
	$("#multi_price_btn").click(function(){
		$(".start-price").val($("#price").val());
		$("#list_table").find("input[type='checkbox']").attr("checked", true);
	});
	$("#multi_quantity_btn").click(function(){
		$(".quantity").val($("#quantity").val());
		$("#list_table").find("input[type='checkbox']").attr("checked", true);
	});
});
</script>
<form action="<?=url('Online::EbayListing/ReviseInventorySave')?>" method="post">
<table>
	<tr>
		<td>&nbsp;&nbsp;</td>
	</tr>
	<tr>
		<td><input type="text" name="price" id="price"/></td>
		<td><input type="button" value="批量填价格" class="button" style="width: 120px" id="multi_price_btn" /></td>
	</tr>
	<tr>
		<td>&nbsp;&nbsp;</td>
	</tr>
	<tr>
		<td><input type="text" name="quantity" id="quantity"/></td>
		<td><input type="button" value="批量填数量" class="button" style="width: 120px" id="multi_quantity_btn" /></td>
	</tr>
	<tr>
		<td>&nbsp;&nbsp;</td>
	</tr>
</table>
<table id="list_table" class="list_table">
<thead>
	<tr>
		<th width="120">店铺</th>
		<th width="130">Item ID</th>
		<th width="120">SKU</th>
		<th width="120">Price</th>
		<th width="100">Quantity</th>
		<th width="50">选中</th>
	</tr>
</thead>
<tbody>
	<?foreach ($listing as $l):?>
	<?foreach ($l as $k => $li):?>
	<tr>
		<?php if ($k == 0):?>
		<td rowspan="<?=count($l)?>"><?=$li['shop_name']?></td>
		<td rowspan="<?=count($l)?>">
			<?=$li['item_id']?>
			<input type="hidden" name="listing[<?=$li['online_ebay_listing_id']?>][id]" value="<?=$li['online_ebay_listing_id']?>" />
		</td>
		<?endif;?>
		<td>
			<?=$li['sku']?>
			<input type="hidden" name="listing[<?=$li['online_ebay_listing_id']?>][item][<?=$li['id']?>][sku]" value="<?=$li['sku']?>" />
		</td>
		<td>
			<span><?=$li['currency_symbol']?></span>
			<input type="text" name="listing[<?=$li['online_ebay_listing_id']?>][item][<?=$li['id']?>][start_price]" value="<?=$li['start_price']?>" class="start-price" size="7">
		</td>
		<td><input type="text" name="listing[<?=$li['online_ebay_listing_id']?>][item][<?=$li['id']?>][quantity]" value="<?=$li['quantity']?>" class="quantity" size="7" /></td>
		<td><input type="checkbox" name="listing[<?=$li['online_ebay_listing_id']?>][item][<?=$li['id']?>][checked]" value="1" /></td>
	</tr>
	<?endforeach;?>
	<?endforeach;?>
</tbody>
</table>
<input type="hidden" name="<?=Q::ini('unique_token_name')?>" value="<?=Helper_BSS_Normal::genToken()?>" />
<input type="submit" value="修改" class="button" />
</form>
<?php $this->_endblock();?>